<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>查询统计管理</title>
<meta name="decorator" content="default"/>
<script src="${ctxStatic}/common/change/change.js"></script>
<style type="text/css">		
#contentTable td ,#contentTable th{
	text-align: center;
}
.minWidth {
	min-width: 177px;
}	
</style>
<script type="text/javascript">
	$(document).ready(function() {
		debugger;
		initgNum(vaccAmount.gNum,vaccAmount.gName);
		initVaccName(vaccAmount.companyCode,vaccAmount.vaccineId);
		$(".vaccineCompany").change(function(){
			initCompanyName($(this).val());
		});
		$(document).on("click","#btnReset",function(){
			$("#cType").val("").select2();
			$("#vaccineId").val("").select2();
			$("#orderType").val("").select2();
			$("#companyCode").val("").select2();
			$("#batchType").val("").select2();
			$("#gNum").val("").select2();
			$("#batchNo").val("");
			$("#storeCodeId").val("");
			$("#storeCodeName").val("");
		});
	});
	debugger;
	var vaccAmount = JSON.parse('${fns:toJson(vaccAmount)}');
	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
       	return false;
       }
	function down(){
		top.$.jBox.confirm("确认要分地区疫苗库存量统计数据吗？","系统提示",function(v,h,f){
			if(v=="ok"){
				$("#searchForm").attr("action","${ctx}/area/vaccinate/countAmountExport");
				$("#searchForm").submit();
				$("#searchForm").attr("action","${ctx}/area/vaccinate/countVaccNum");
			}
		},{buttonsFocus:1});
		top.$('.jbox-body .jbox-icon').css('top','55px');
	}
</script>
</head>
<body>
	<ul class="nav nav-tabs">
	    <li class="active"><a href="#">分地区疫苗库存量统计</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="vaccAmount" action="${ctx}/area/vaccinate/countVaccNum" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<div class="breadcrumb">
			<table class="table table-bordered">
				<tr>
					<th>地区:</th>
					<td>
						<sys:treeselect2 id="storeCode" name="storeCode" value="${vaccAmount.storeCode}" labelName="storeName" labelValue="${vaccAmount.storeName}"
					        title="机构" url="/sys/office/treeData" cssClass="input-medium" layer = "true" disabled="${office.grade == '50' ? 'disabled' : 'false'}"/>
					</td>
					<th>疫苗/注射器：</th>
					<td>
						<form:select path="batchType" id="batchType" class="span2 minWidth">
							<form:option value="" label="--请选择--"/>
							<form:options items="${fns:getDictList('batch_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select> 
					</td> 
					<th>疫苗类型：</th>
					<td>
						<form:select path="cType" id="cType" class="span2 minWidth">
							<form:option value="" label="--请选择--"/>
							<form:options items="${fns:getDictList('bs_vaccineInfo_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select> 
					</td>
				</tr>
				<tr>
					<th>疫苗大类名称:</th>
					<td>
						<form:select path="gNum" id="gNum" class="span2 minWidth vaccinegName" >
							<form:option value="" label="--请选择--"/>
						</form:select>
					</td>
					<th>疫苗小类名称:</th>
					<td>
						<form:select path="vaccineId" id="vaccineId" class="span2 minWidth vaccineCompany" >
							<form:option value="" label="--请选择--"/>
						</form:select>
					</td>
					<th>生产企业：</th>
					<td>
						<form:select path="companyCode" id="companyCode" class="span2 minWidth changeCompany">
						    <form:option value="" label="--请选择--"/> 
						</form:select>
					</td>
				</tr>
				<tr>
					<th>查询范围</th>
					<td>
						<form:checkboxes path="grade" items="${fns:getDictList('sys_office_grade_3')}" values="${vaccAmount.grade}" itemLabel="label" itemValue="value"/>
					</td>
					<th>批号:</th>
					<td colspan="3">
						<form:input path="batchNo" id="batchNo" class="span2 minWidth" value= "${vaccAmount.batchNo}"/>
					</td>
				</tr>
			</table>
		</div>
		<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
		<input id="btnReset" class="btn btn-primary" type="button" value="重置"/>
		<input onclick="down()" class="btn btn-primary" type="button" value="导出"/>
	</form:form>
	
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			    <th>编号</th>
			    <th>地区名称</th>
				<th>单位</th>
				<th>疫苗/注射器名称</th>
				<th>疫苗/注射器属性</th>
				<th>生产企业</th>
				<th>批号</th>
				<th>规格(剂/支或粒)</th>
				<th>剂量</th>
				<th>剂型</th>
				<th>有效期</th>
				<th>成本价</th>
				<th>实际库存</th>
				<!-- <th>可用库存</th> -->
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="vaccAmount" begin="0"  varStatus="status">
			<tr>
				<td>
					${(page.pageNo-1)*page.pageSize+status.index+1 }
				</td>
				<td>
					${vaccAmount.areaName}
				</td>
				<td>
					${vaccAmount.unitName}
				</td>
				<td>
					${vaccAmount.vaccName}
				</td>
				<td>
					${fns:getDictLabel(vaccAmount.cType,'bs_vaccine_type','') } 
				</td>
				<td>
					${vaccAmount.companyName}
				</td>
				<td>
				    ${vaccAmount.batchNo}
					<c:if test="${not empty vaccAmount.secondBatchno}">
				        <span title="(查询批号时不需要带入亚批号)" style="color: #2fa4e7;">-${vaccAmount.secondBatchno}</span>
				    </c:if>
				</td>
				<c:if test="${vaccAmount.batchType==2}">
					<td>${fns:getDictLabel(vaccAmount.spec, "syringe_spec", "")}</td>
				</c:if>
				<c:if test="${vaccAmount.batchType==1}">
					<td>${vaccAmount.spec}</td>
				</c:if>
				<c:if test="${vaccAmount.batchType==2}">
					<td>-</td>
				</c:if>
				<c:if test="${vaccAmount.batchType==1}">
					<td>${vaccAmount.dose}</td>
				</c:if>
				<c:if test="${vaccAmount.batchType==2}">
					<td>-</td>
				</c:if>
				<c:if test="${vaccAmount.batchType==1}">
					<td>${vaccAmount.doseType}</td>
				</c:if>
				<td>
					<fmt:formatDate value="${vaccAmount.outBoundDate}" pattern="yyyy-MM-dd"/>  
				</td>
				<td style = "text-align: right; padding-right: 10px">
					￥${vaccAmount.orignprice}
				</td>
				<td>
					${vaccAmount.vaccNum}
				</td>
				<%-- <td>
					${vaccAmount.vaccNum - vaccAmount.storenumF}
				</td> --%>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>